package com.frame.service.impl;

import com.frame.service.LoginManager;
import org.springframework.stereotype.Service;

import com.base.dao.DAO;
import com.base.util.PageData;


import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lee on 2016/6/23.
 */
@Service("loginService")
public class LoginServiceImpl implements LoginManager {

    @Resource(name = "daoSupport")
    private DAO dao;
    public PageData getUserByRealPass(PageData pd) {
        PageData user =  new PageData();
        try {
            user = (PageData) dao.findForObject("UserMapper.getUserByRealPass",pd);
        } catch (Exception e) {
            e.printStackTrace();
            return new PageData();
        }
        return user;
    }

    public PageData getUserByPassAndName(PageData pd) {
        PageData user =  new PageData();
        try {
            user = (PageData) dao.findForObject("UserMapper.getUserByPassAndName",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return user;
    }

    public PageData getUserByUserID(PageData pd) {
        PageData user = new PageData();
        try {
            user = (PageData) dao.findForObject("UserMapper.getUserByUserID",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  user;

    }

    public void updateUserInfo(PageData pd) {
        try {
            dao.update("UserMapper.userUpdateInfo",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public List<PageData> getDepartment(PageData pd) {
        List<PageData> list = new ArrayList<PageData>();
        try {
            list = (List<PageData>) dao.findForList("UserMapper.getDepartment",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
